CS424 Assignment 5
Due March 8 2007.
-
Use Python NWS to implement a simple result parallel prime finder that tests each
integer from 2 to n
for primality by testing by division for all possible factors (I suggest 2,3,5,7,9...).
Each test should be independent, i.e. it should not depend on other
tasks. Return a boolean vector that indicates the primality of each integer tested. You
should use eachElem() to create the tasks.
- Modify your solution to problem 1 to make use of previously determined primes to test each integer.
This will be similar to figure 5.2 on page 87, but note that your program will differ in a
couple of important ways from the Linda version in the book. Is there an operation you
wish you had in NWS that would make things more natural?
- Implement the specialist parallel prime finder that uses the sieve of Eratosthenes, but
modify it to do chunking, i.e. rather than have each process own just 1 prime,
let it own k primes. Note that in NWS, you can't easily do the dynamic process
creation done in Linda via eval. As a workaround, create an initial, fixed pool of 20
"generic prime filters". These processes will hang around NWS, looking for a set of primes to own.
When they get a set, they'll permanently become the filter for those primes. You'll only be able
to handle 20 * CHUNK primes this way, of course.
- How is the load spread among the processes in problem 3? Can you think of any solutions?
Implement your solution and see if it helps the situation.